<?php

class ForceSSLFilter extends sfFilter
{
    /**
     * Executes this filter.
     *
     * @param sfFilterChain $filterChain A sfFilterChain instance
     */
    public function execute($filterChain)
    {
        $context = $this->getContext();
        
        if ($context->getRequest()->isSecure()) {
            $redirectToSSL = false;
        } else {
            $redirectToSSL = $context->getActionStack()->getLastEntry()
                ->getActionInstance()->getSecurityValue('force_ssl', false);
        }
        
        if ($redirectToSSL) {
            $this->getContext()->getController()->forward('default', 'SSL');
        } else {
            $filterChain->execute();
        }
    }
}

?>
